package com.net.xpay.common.manager.impl;

import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.net.common.dao.BasicMapper;
import com.net.xpay.common.dao.FlexibleStaffCardMapper;
import com.net.xpay.common.domain.FlexibleStaffCard;
import com.net.xpay.common.manager.FlexibleStaffCardManager;
import com.net.common.manager.AbstractManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


@Component
public class FlexibleStaffCardManagerImpl extends AbstractManager<FlexibleStaffCard> implements FlexibleStaffCardManager{

    @Autowired
    private FlexibleStaffCardMapper mapper;


    @Override
    protected BasicMapper<Long, FlexibleStaffCard> getMapper() {
        return mapper;
    }

    @Override
    public FlexibleStaffCard findByIdentity(Long userId, String identity, String hireIdentity) {
        Preconditions.checkArgument(userId != null && !Strings.isNullOrEmpty(identity) && !Strings.isNullOrEmpty(hireIdentity));
        FlexibleStaffCard condition = new FlexibleStaffCard();
        condition.setUserId(userId);
        condition.setIdentity(identity);
        condition.setHireIdentity(hireIdentity);
        return getByCondition(condition);
    }

    @Override
    public FlexibleStaffCard getByOutBizNo(String outBizNo) {
        Preconditions.checkArgument(!Strings.isNullOrEmpty(outBizNo));
        FlexibleStaffCard condition = new FlexibleStaffCard();
        condition.setOutBizNo(outBizNo);
        return getByCondition(condition);
    }

    @Override
    public FlexibleStaffCard findByImportBizNo(Long userId, String importBizNo) {
        Preconditions.checkArgument(userId != null && !Strings.isNullOrEmpty(importBizNo));
        FlexibleStaffCard condition = new FlexibleStaffCard();
        condition.setUserId(userId);
        condition.setImportBizNo(importBizNo);
        return getByCondition(condition);
    }

    @Override
    public FlexibleStaffCard findByLoanAgreementNo(Long userId, String agreementNo) {
        Preconditions.checkArgument(userId != null && agreementNo != null);
        FlexibleStaffCard condition = new FlexibleStaffCard();
        condition.setUserId(userId);
        condition.setAgreementNo(agreementNo);
        return getByCondition(condition);
    }
}
